package cn.buildoncloud.labor.workermanapplet.adapter;

import cn.buildoncloud.labor.workermanapplet.interceptor.AuthInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Description: cn.buildoncloud.labor.workermanapplet.adapter
 * Created by CuiZibo on 2018/11/1 15:25
 */
@Configuration
public class AppletAdapter implements WebMvcConfigurer {

    @Autowired
    private AuthInterceptor authInterceptor;


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")
        //excludePathPatterns 用于排除拦截
                .excludePathPatterns("/authority/getOpenId")
                .excludePathPatterns("/test/**")
                .excludePathPatterns("/authority/sendVerificationCode")
                .excludePathPatterns("/authority/bind")
                .excludePathPatterns("/authority/saveOrUpdateAppletUser")
                .excludePathPatterns("/accessRecord/showFileByBase64")
                .excludePathPatterns("/file/pageShowFile")
                .excludePathPatterns("/static/**")


        ;
    }

}
